<template>
  <div class="zong1">
    <div class="toptitle">设备数据</div>
    <!-- 上侧一些选择器和输入框，按钮 -->
    <div class="topselect">
      <el-select v-model="place" class="m-2" placeholder="请选择设备位置" size="small">
        <el-option
          v-for="item in placelist"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        />
      </el-select>
      <el-select v-model="ifonline" class="m-2" placeholder="全部在线/离线状态" size="small">
        <el-option
          v-for="item in ifonlinelist"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        />
      </el-select>
      <el-select v-model="alertzt" class="m-2" placeholder="全部警报状态" size="small">
        <el-option
          v-for="item in alertztlist"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        />
      </el-select>
      <el-input v-model="devicename" class="m-2"  placeholder="请输入设备名称" style="width:300px;" size="small">
      </el-input>
      <el-button type="primary" size="small" class="m-3" @click="down">下载</el-button>
      <el-button type="primary" size="small" class="m-3" @click="prints">打印</el-button>
    </div>
    <!-- 下边的表格 -->
    <el-table border :data="tableData"  style="width: 97%;margin-left:23px; margin-top:20px;height:400px;background:#f5f7fa;" :header-cell-style="{background:'#b4c7e7',color:'#333333'}">
      <el-table-column type="selection" width="55" />
      <el-table-column prop="a1" label="设备名称" width="90" align="center"/>
      <el-table-column prop="a2" label="设备位置" width="85" align="center"/>
      <!-- <el-button type="info" :icon="Message" circle /> -->
      <!-- <el-button type="danger" :icon="Delete" circle /> -->
      <el-table-column label="在线状态" width="80" align="center">
        <template #default="scope">
          <div class="rgz">
            <div v-if="scope.row.a3 ==1" class="greeny"></div>
            <div v-if="scope.row.a3 ==0" class="redy"></div>
          </div>
        </template>
      </el-table-column>
      <!-- <el-table-column prop="a3" label="在线状态" width="80" align="center"/> -->
      <el-table-column prop="a4" label="警报状态" width="80" align="center">
        <template #default="scope">
          <div class="rgz">
            <div v-if="scope.row.a3 ==1" >在线</div>
            <div v-if="scope.row.a3 ==0" >离线</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column  label="实时数据" class="lie" align="center" width="1060">
        <template #default="scope">
            <el-table :data="scope.row.lists" style="width: 100%;height:50px " :header-row-style="{height:'20px' }" :header-cell-style="{background:'#b4c7e7',color:'#333' }">
              <el-table-column label="回风温度" width="75"  align="center">{{scope.row.lists[0]}}</el-table-column>
              <el-table-column label="回风CO2" width="75"  align="center">{{scope.row.lists[1]}}</el-table-column>
              <el-table-column prop="q3" label="室内温度3" width="85" align="center">{{scope.row.lists[2]}}</el-table-column>
              <el-table-column prop="q4" label="室内温度" width="75" align="center">{{scope.row.lists[3]}}</el-table-column>
              <el-table-column prop="q5" label="回风机频率" width="100" align="center" >{{scope.row.lists[4]}}</el-table-column>
              <el-table-column prop="q6" label="送风机频率" width="100"  align="center">{{scope.row.lists[5]}}</el-table-column>
              <el-table-column prop="q1" label="水阀" width="50" align="center" >{{scope.row.lists[6]}}</el-table-column>
              <el-table-column prop="q1" label="转轮" width="50"  align="center">{{scope.row.lists[7]}}</el-table-column>
              <el-table-column prop="q1" label="新风阀" width="75"  align="center">{{scope.row.lists[8]}}</el-table-column>
              <el-table-column prop="q1" label="旁通阀" width="75" align="center" >{{scope.row.lists[9]}}</el-table-column>
              <el-table-column prop="q1" label="排风温度" width="75"  align="center">{{scope.row.lists[10]}}</el-table-column>
              <el-table-column prop="q1" label="新风温度" width="75"  align="center">{{scope.row.lists[11]}}</el-table-column>
              <el-table-column prop="q1" label="回风温度" width="75" align="center" >{{scope.row.lists[12]}}</el-table-column>
              <el-table-column prop="q1" label="送风温度" width="75"  align="center">{{scope.row.lists[13]}}</el-table-column>
            </el-table>
        </template> 
      </el-table-column>
    </el-table>
    <!-- 分页 -->
      <div class="demo-pagination-block">
        <el-pagination
          v-model:currentPage="currentPage"
          v-model:page-size="pageSize"
          :page-sizes="[100, 200, 300, 400]"
          :small=true
          layout="total, sizes, prev, pager, next, jumper"
          :total="400"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
  </div>
</template>

<script>
import {ref,reactive,watch} from 'vue'
export default {
setup(){
  const currentPage = ref(5)
  const pageSize = ref(100)
  
  const handleSizeChange = (val) => {
    console.log(`${val} items per page`)
  }
  const handleCurrentChange = (val) => {
    console.log(`current page: ${val}`)
  }


  var tableData = reactive([
  {
    a1: '12313',
    a2: 'Tom',
    a3: '0',
    a4: '0',
    lists:[1,23,43,123,22,3,3,5,6,7,19,8,99,5]
  },
  {
    a1: '333333',
    a2: 'Tom',
    a3: '0',
    a4: '0',
    lists:[1,23,43,123,22,3,3,5,6,7,19,8,99,5]
  },
  {
    a1: '2222222',
    a2: 'Tom',
    a3: '1',
    a4: '1',
    lists:[1,23,43,123,22,3,3,5,6,7,19,8,99,5]
  },
  {
    a1: '44444',
    a2: 'Tom',
    a3: '1',
    a4: '1',
    lists:[1,23,43,123,22,3,3,5,6,7,19,8,99,5]
  },
])
  var place = ref('')
  const placelist = [
      {
        value: 'Option1',
        label: 'Option1',
      },
      {
        value: 'Option2',
        label: 'Option2',
      },
      {
        value: 'Option3',
        label: 'Option3',
      },
      {
        value: 'Option4',
        label: 'Option4',
      },
      {
        value: 'Option5',
        label: 'Option5',
      },
  ]
  var ifonline = ref('')
  const ifonlinelist = [
      {
        value: 'Option1',
        label: 'Option1',
      },
      {
        value: 'Option2',
        label: 'Option2',
      },
      {
        value: 'Option3',
        label: 'Option3',
      },
      {
        value: 'Option4',
        label: 'Option4',
      },
      {
        value: 'Option5',
        label: 'Option5',
      },
  ]
  var alertzt = ref('')
  const alertztlist = [
    {
      value: 'Option1',
      label: 'Option1',
    },
    {
      value: 'Option2',
      label: 'Option2',
    },
    {
      value: 'Option3',
      label: 'Option3',
    },
    {
      value: 'Option4',
      label: 'Option4',
    },
    {
      value: 'Option5',
      label: 'Option5',
    },
  ]
  var devicename = ref('')
  watch(place, (newValue) => {
      alert(newValue)
    })
  watch(ifonline, (newValue) => {
      alert(newValue)
    })
  watch(alertzt, (newValue) => {
      alert(newValue)
    })
  watch(devicename, (newValue) => {
      alert(newValue)
    })
  function down(){
    alert('下载')
  }
   function prints(){
    alert('打印')
  }
  return{
    tableData,place,ifonline,alertzt,devicename,placelist,ifonlinelist,alertztlist,down,prints,currentPage,pageSize
    ,handleSizeChange,handleCurrentChange
  }
}
}
</script>
<style  >
.zong1{
  width: 100%;
  height: 550px;
  background: white;
}
.lie{
  background: red;
}
.el-table__cell{
    padding: 0 !important;
}
.topselect{
  margin-top: 10px;
  padding-left: 450px;
}
.el-table .cell{
  padding: 0;
}
.m-2{
  margin-left: 20px;
  width: 150px;
}
.m-3{
  width: 80px;
  margin-left: 15px;
  /* background: #8faadc; */
}
.toptitle{
  padding-left: 30px;
  padding-top: 20px;
  font-size: 15px;
  font-weight: 600;
  color: #4d62a5;
  border-bottom: 2px solid #d9deec;
  padding-bottom: 10px;
}
.el-table .el-table__cell{
  background: #f5f7fa;
}
.demo-pagination-block{ 
  float: right;
  margin-right: 20px;
  margin-top: 8px;
}
.redy{
  border-radius: 50%;
  width: 1.8rem;
  height: 1.8rem;
  background: red;
  margin-left: 25px;
}
.greeny{
  border-radius: 50%;
  width: 1.8rem;
  height: 1.8rem;
  background: #0db459;
  margin-left: 25px;
}
.rgz{
  text-align: center;
}

</style>